package com.xuan.book.service;

import com.xuan.book.constants.Constants;
import com.xuan.book.mapper.UserInfoMapper;
import com.xuan.book.model.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpSession;

@Service
public class UserService {
    @Autowired
    private UserInfoMapper userInfoMapper;

    public boolean verify(String userName, String password, HttpSession session) {
        UserInfo userInfo = userInfoMapper.queryByName(userName);
        if(userInfo != null && userInfo.getPassword().equals(password)) {
             session.setAttribute(Constants.USER_SESSION_KEY, userInfo);
            return true;
        }
        return false;
    }


}
